package com.topone.dataObject;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.topone.Enum.CouponEnum;
import com.topone.Utils.EnumUnitl;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 优惠券信息
 * Created by Administrator on 2017/11/6,0006.
 */
@Entity
@DynamicUpdate
@Data
@EntityListeners(AuditingEntityListener.class)
public class TcCoupon {
    @Id
    private String couponId;        //优惠券Id
    private String couponCode;      //优惠券code
    private String couponName;      //优惠券名称
    private Integer couponType;  //优惠券种类
    private Integer couponStock;      //优惠券数量
    private BigDecimal couponPrice; //优惠券价格
    private BigDecimal discountPrice; //抵扣价
    private Integer   creditPrice =0;   //积分价格
    private  String useCondition;    //折扣最低条件
    private String couponRank;      //优惠券使用范围
    private Integer couponStatus= CouponEnum.UP.getCode();    //优惠券状态
    private String couponIcon;       //优惠券图标
    private String bussinessId;     //商家id
    private String imageId;
    private Integer isFlashsale;    //是否为限时抢购优惠券

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @Temporal(TemporalType.TIMESTAMP)
    private Date activityDurationStart;  //活动开始有效期

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @Temporal(TemporalType.TIMESTAMP)
    private Date activityDurationEnd;  //活动结束有效期

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @Temporal(TemporalType.TIMESTAMP)
    private Date useDurationStart;       //消费开始有效期

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @Temporal(TemporalType.TIMESTAMP)
    private Date useDurationEnd;       //消费结束有效期

    @JSONField(format = "HH:mm:ss")
    @Temporal(TemporalType.TIME)
    private Date useDurationEndTime;  //每天活动结束有效期

    @JSONField(format = "HH:mm:ss")
    @Temporal(TemporalType.TIME)
    private Date useDurationStartTime;       //每天消费开始有效期
    private BigDecimal lowestConsume;    //最低消费
    private BigDecimal couponValue;     //优惠券面额
    private Integer couponNumLimit;  //领券限额
    @CreatedDate
    private Date createTime;
    @LastModifiedDate
    private Date updateTime;

    //private  Bussiness bussiness;

    @JsonIgnore
    public CouponEnum getCouponEnum(){
        return  EnumUnitl.getByCode(couponStatus,CouponEnum.class);

    }
}
